package com.sl.u_push_plugin

class ResaultData {
    private var result: MutableMap<String, Any>? = null
    private var innerResult: MutableMap<String, Any>? = null
    private var type: Int = 0
    fun Builder(): ResaultData {
        result = mutableMapOf()
        return this
    }

    fun initType(type: Int): ResaultData {
        this.type = type
        return this;
    }

    fun initData(key: String, value: Any): ResaultData {
        innerResult = innerResult ?: mutableMapOf()
        innerResult?.put(key, value)
        return this;
    }

    fun build(): MutableMap<String, Any> {
        result?.put("type", type)
        innerResult?.run {
            result?.put("data", this)
        }

        return result ?: mutableMapOf()
    }

    fun isEmpty(): Boolean{
        if(innerResult == null){
            return true
        }
        return innerResult!!.isEmpty();
    }

}